<template>
  <div>
    <v-header :title="$route.params.type + '详情页'">
      <v-back></v-back>
    </v-header>
    <van-tabs
      v-model="active"
      background="rgb(255,99,71)"
      color="#fff"
      line-width="20px"
      title-inactive-color="#fff"
      title-active-color="#fff"
    >
      <van-tab title="商品"></van-tab>
      <van-tab title="评价"></van-tab>
      <van-tab title="详情"></van-tab>
      <van-tab title="推荐"></van-tab>
    </van-tabs>
    <!-- 商品图片 -->
    <div
      id="img"
      :style="
        'background-image: url(http://localhost:3000' + goodInfo.img + ');'
      "
    >
      <div>
        <span><van-icon name="star-o" /></span>
      </div>
      <!-- <img :src="'http://localhost:3000'+goodInfo.img" alt=""> -->
      <div>8/8</div>
    </div>
    <!-- 商品的详细信息 -->
    <div id="pice_msg">
      <div class="title">
        <div class="pice">
          ￥<strong>{{ goodInfo.market_price }}</strong
          ><del>￥{{ goodInfo.price }}</del>
        </div>
        <div>
          <span class="iconfont">&#xe65d; </span>
          <p>收藏</p>
        </div>
      </div>
      <div class="message">
        <h2>{{ goodInfo.goodsname }}</h2>
        <h3>敏感肌可用，控油祛痘、男女可用、泡沫绵密、净透毛孔</h3>
      </div>
      <div class="discount">11.11限时299元起</div>
      <div class="msg_time">
        <p class="textflow">
          此商品于2020-11-11,00点结束闪购特卖，品牌美妆闪购专场
        </p>
        <p><a href="">查看></a></p>
      </div>
    </div>
    <!-- 购买选项 -->
    <div id="option">
      <!-- 领券 -->
      <article class="ticket clearfix">
        <div class="fl">领券</div>
        <div class="fl">
          <p>300</p>
          <p>50</p>
          <p>10</p>
        </div>
      </article>
      <!-- 分期 -->
      <article class="ticket clearfix">
        <div class="fl">分期</div>
        <div
          class="fl clearfix"
          style="color: #666666; display: block; line-height: 0.35rem"
        >
          可选/3/6/12期
          <span class="fr" style="margin-right: 0.1rem">></span>
        </div>
      </article>
    </div>
    <!-- 底部的 -->
    <van-goods-action>
      <van-goods-action-icon icon="chat-o" text="客服"/>
      <van-goods-action-icon icon="cart-o" text="购物车"/>
      <van-goods-action-icon icon="shop-o" text="店铺" />
      <van-goods-action-button type="warning" text="加入购物车" @click="onClickButton"/>
      <van-goods-action-button
        type="danger"
        text="立即购买"
      />
    </van-goods-action>
  </div>
</template>

<script>
import { getGoodsInfo, shopCarAdd } from "@/request/api.js";
export default {
  data() {
    return {
      active: 0,
      goodInfo: {},
      addDate: {
        uid: "",
        goodsid: "",
        num: 1,
      },
    };
  },
  async created() {
    this.addDate.goodsid = this.$route.params.id;
    let res = await getGoodsInfo(this.addDate.goodsid);
    this.goodInfo = res.data.list[0];
    this.addDate.uid = JSON.parse(localStorage.getItem("userInfo")).uid;
  },
  methods: {
    async onClickButton() {
      let res=await shopCarAdd(this.addDate);
      this.$Toast.success('添加成功！')
    },
  },
};
</script>

<style scoped>
#img {
  height: 3.75rem;
  /* background-image: url(../images/1.png); */
  background-repeat: no-repeat;
  background-size: cover;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0.15rem;
  box-sizing: border-box;
}
#img div:nth-child(1) {
  height: 0.24rem;
  width: 0.24rem;
  background: rgba(51, 51, 51, 0.8);
  font-size: 0.13rem;
  text-align: center;
  line-height: 0.24rem;
  color: #ffffff;
  border-radius: 50% 50%;
}
#img div:nth-child(2) {
  background: rgba(51, 51, 51, 0.8);
  border-radius: 0.09rem;
  width: 0.4rem;
  height: 0.18rem;
  font-family: PingFangSC-Light;
  font-size: 0.14rem;
  color: #ffffff;
  letter-spacing: 0;
  text-align: center;
  line-height: 0.18rem;
}
#pice_msg {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  background-color: #fff;
  padding: 0.1rem;
  box-sizing: border-box;
  height: 1.45rem;
}
#pice_msg .title {
  display: flex;
  justify-content: space-between;
}
#pice_msg .title div:nth-child(2) {
  width: 0.3rem;
  height: 0.24rem;
  font-family: PingFangSC-Light;
  font-size: 0.1rem;
  color: #ff6040;
  letter-spacing: 0;
  text-align: center;
  line-height: 0.1rem;
}
#pice_msg .title div:nth-child(2) p {
  margin-top: 0.0301rem;
}
#pice_msg .pice {
  font-weight: 600;
  font-family: PingFangSC-Semibold;
  font-size: 0.14rem;
  color: #ff6040;
  line-height: 0.12rem;
}
#pice_msg .pice strong {
  font-size: 0.3rem;
  color: #ff6040;
  line-height: 0.24rem;
}
#pice_msg .pice del {
  font-size: 0.14rem;
  color: #999999;
  line-height: 0.12rem;
  margin-left: 0.05rem;
}
#pice_msg .message h2 {
  font-family: PingFangSC-Regular;
  font-size: 0.16rem;
  color: #333333;
  line-height: 0.16rem;
  font-weight: 600;
}
#pice_msg .message h3 {
  font-family: PingFangSC-Regular;
  font-size: 0.14rem;
  color: #999999;
  line-height: 0.14rem;
  margin-top: 0.04rem;
}
#pice_msg .discount {
  display: inline-block;
  align-self: flex-start;
  padding: 0 0.03rem;
  height: 0.16rem;
  background: #ff8066;
  font-family: PingFangSC-Light;
  font-size: 0.1rem;
  color: #ffffff;
  line-height: 0.1615rem;
}
#pice_msg .msg_time {
  background: #f2f2f2;
  height: 0.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: PingFangSC-Light;
  font-size: 0.1rem;
  color: #999999;
}
#pice_msg .msg_time p:nth-child(2) {
  width: 0.48rem;
  font-family: PingFangSC-Medium;
  font-size: 0.1rem;
  font-weight: 600;
  text-align: right;
}
#pice_msg .msg_time p:nth-child(2) a {
  color: #ff6040;
}
#option {
  margin-top: 0.1rem;
  padding: 0.1rem 0 0 0.1rem;
  background-color: #fff;
}
#option .ticket div:nth-child(1) {
  font-family: PingFangSC-Semibold;
  font-size: 0.12rem;
  color: #333333;
  line-height: 0.35rem;
  font-weight: 600;
  height: 0.35rem;
}
#option .ticket div:nth-child(2) {
  width: 3.2rem;
  border-bottom: 0.01rem solid #ccc;
  display: flex;
  margin-left: 0.2rem;
  align-items: center;
  height: 0.35rem;
}
#option .ticket div:nth-child(2) p {
  padding: 0 0.1rem;
  height: 0.16rem;
  line-height: 0.16rem;
  /* background-image: url(../images/full.png); */
  background-repeat: no-repeat;
  background-size: contain;
  margin-right: 0.1rem;
  font-family: PingFangSC-Semibold;
  font-size: 0.1rem;
  color: #663014;
}
</style>